class Service {
  api(parmas: any): any {

    uni.showLoading({
      title: '加载中'

    })
    return new Promise<void>((resolve, reject) => {
      uni.request({
        url: parmas.url, //请求的url
        method: parmas.methods || "GET",
        data: parmas.data || {},
        success: (res: any) => {
          resolve(res.data)
        },
        fail: (res) => {
          reject(res)
        },
        complete: () => {
          uni.hideLoading();
        }
      })

    })
  }
  get(parmas: any) {
    parmas.methods = 'GET'
    return this.api(parmas)
  }
  delete(parmas: any) {
    parmas.methods = 'DELETE'
    return this.api(parmas)
  }
  post(parmas: any) {
    parmas.methods = 'POST'
    return this.api(parmas)
  }
}
export default Service